package sv.com.renacempleo.dao.ctg;
 
import java.util.List;
 
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
 
import sv.com.renacempleo.dao.BaseDaoImpl;
import sv.com.renacempleo.dto.ctg.CtgEmpleados;
import sv.com.renacempleo.exception.WebException;
 
public class CtgEmpleadoDaoImpl extends BaseDaoImpl implements CtgEmpleadoDao{
 
      @SuppressWarnings("unchecked")
      public List<Object[]> findAllActivesAsArray() throws WebException {
            DetachedCriteria criteria = DetachedCriteria.forClass(CtgEmpleados.class);
            criteria.addOrder(Order.asc("ctgEmpleadoId"));
            criteria.add(Restrictions.eq("ctgEmpleadoEstado", "1"));
            criteria.setProjection(Projections.projectionList().
                        add(Projections.property("ctgEmpleadoNombres")).
                        add(Projections.property("ctgEmpleadoApellidos")).
                        add(Projections.property("ctgEmpleadoId"))
            );         
           
            return (List<Object[]>) findByCriteria(criteria);
      }
 
      @SuppressWarnings("unchecked")
      public List<Object[]> findAllAsArray() throws WebException {
            DetachedCriteria criteria = DetachedCriteria.forClass(CtgEmpleados.class);
            criteria.addOrder(Order.asc("ctgEmpleadoId"));
            criteria.createAlias("sgdUsuario", "sgdUsuario");
            criteria.createAlias("ctgOficina", "ctgOficina");
            criteria.createAlias("ctgCargoEmpleado", "ctgCargoEmpleado");
            criteria.setProjection(Projections.projectionList().
                        add(Projections.property("ctgEmpleadoId")).
                        add(Projections.property("ctgEmpleadoNombres")).
                        add(Projections.property("ctgEmpleadoApellidos")).
                        add(Projections.property("sgdUsuario.sgdUsuarioId")).
                        add(Projections.property("sgdUsuario.sgdUsuarioUsuario")).
                        add(Projections.property("ctgOficina.ctgOficinaId")).
                        add(Projections.property("ctgOficina.ctgOficinaNombre")).
                        add(Projections.property("ctgEmpleadoFechaIngreso")).
                        add(Projections.property("ctgEmpleadoFechaRetiro")).
                        add(Projections.property("ctgEmpleadoEstado")).
                        add(Projections.property("ctgEmpleadoPuesto")).
                        add(Projections.property("ctgCargoEmpleado.ctgCatalogoId")).
                        add(Projections.property("ctgCargoEmpleado.ctgCatalogoNombre")).
                        add(Projections.property("ctgEmpleadoCodigo"))
            );         
            return (List<Object[]>) findByCriteria(criteria);
      }
 
}